﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 图片生成工具
{
    class Program
    {
        static void Main(string[] args)
        {
            ///生成指定格式的图片
            ///纯色图片
            GetImg();


        }

        public static void GetImg()
        {

            Random rd = new Random();
            int num = rd.Next(1, 7);//1-7随机数
            int initWidth = 256;
            int initHeight = 256;

            for (var c = '\uff41'; c <= '\uff5a'; c++)
            {
                Bitmap image = new Bitmap(initWidth, initHeight);//初始化大小
                Graphics g = Graphics.FromImage(image);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;//设置图片质量
                num = (int)c;
                switch (num % 8)//设置图片不同背景色
                {
                    case 1:
                        g.Clear(Color.FromArgb(255, 139, 139));
                        break;
                    case 2:
                        g.Clear(Color.FromArgb(97, 191, 173));
                        break;
                    case 3:
                        g.Clear(Color.FromArgb(22, 124, 127));
                        break;
                    case 4:
                        g.Clear(Color.FromArgb(50, 182, 122));
                        break;
                    case 5:
                        g.Clear(Color.FromArgb(191, 181, 215));
                        break;
                    case 6:
                        g.Clear(Color.FromArgb(240, 207, 97));
                        break;
                    case 7:
                        g.Clear(Color.FromArgb(5, 90, 91));
                        break;
                    default:
                        g.Clear(Color.FromArgb(5, 90, 91));
                        break;
                }

                Font f = new Font("Arial ", 88);//, System.Drawing.FontStyle.Bold);//设置字体样式，大小
                Brush b = new SolidBrush(Color.White);
                Brush r = new SolidBrush(Color.FromArgb(166, 8, 8));
                g.DrawString(c.ToString(), f, b, 45, 60);//设置位置
                image.Save(AppDomain.CurrentDomain.BaseDirectory + "\\img\\" + (num).ToString() + ".jpg", ImageFormat.Jpeg);//自己创建一个文件夹，放入生成的图片（根目录下）
            }

        }

    }
}
